﻿<BaseClass:ItemTreeviewBase x:Name="userControl"
                            x:Class="Rio.Framework.Pages.CriteriaControls.ItemTreeview"
                            xmlns:BaseClass="clr-namespace:Rio.Framework.Pages.CriteriaControls.BaseClass"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                            xmlns:converter="clr-namespace:Rio.Framework.Pages.AppCode.Helpers.Converter"
                            mc:Ignorable="d"
                            d:DesignHeight="300"
                            d:DesignWidth="400"
                            telerik:RadDragAndDropManager.AllowDrop="True">

    <BaseClass:ItemTreeviewBase.Resources>

        <converter:SetTrashItemIconConverter x:Key="SetTrashItemIconConverter" />

        <telerik:ContainerBindingCollection x:Key="ContainerBindings">
            <telerik:ContainerBinding PropertyName="IsExpanded"
                                      Binding="{Binding bIsExpanded, Mode=TwoWay}" />
            <telerik:ContainerBinding PropertyName="IsSelected"
                                      Binding="{Binding bIsSelected, Mode=TwoWay}" />
            <telerik:ContainerBinding PropertyName="IsDropAllowed"
                                      Binding="{Binding bIsDropAllowed, Mode=TwoWay}" />
        </telerik:ContainerBindingCollection>

        <telerik:HierarchicalDataTemplate x:Key="TreeViewItemTemplate"
                                          ItemsSource="{Binding Items}"
                                          telerik:ContainerBinding.ContainerBindings="{StaticResource ContainerBindings}">
            <StackPanel Orientation="Horizontal"
                        HorizontalAlignment="Stretch"
                        MouseLeftButtonDown="Item_MouseLeftButtonDown">
                <Image Source="{Binding IsTrashItem, Converter={StaticResource SetTrashItemIconConverter}}"
                       Width="16"
                       Height="16"
                       Margin="0,0,5,0" />
                <TextBlock Text="{Binding Text}"
                           FontWeight="{Binding TextFont}" />
            </StackPanel>
        </telerik:HierarchicalDataTemplate>

    </BaseClass:ItemTreeviewBase.Resources>

    <Grid x:Name="LayoutRoot">
        <telerik:RadTreeView x:Name="TreeViewControlItems"
                             SelectionMode="Single"
                             VerticalAlignment="Stretch"
                             VerticalContentAlignment="Stretch"
                             IsExpandOnDblClickEnabled="True"
                             IsExpandOnSingleClickEnabled="True"
                             ItemPrepared="TreeViewControlItemsItemPrepared"
                             ItemTemplate="{StaticResource TreeViewItemTemplate}"
                             ItemsSource="{Binding ItemsList, ElementName=userControl, Mode=OneWay}"
                             SelectedItem="{Binding CurrentSelectedItem, ElementName=userControl, Mode=TwoWay}" />
    </Grid>
</BaseClass:ItemTreeviewBase>
